<extend name="Base/common"/>
<block name="header">
{:hook('mobileTopNav',array('title'=>$meta_title))}
</block>

<block name="body">
  <div class="order">
    <form action="<gt name="data.total_amount" value="0">{:U('Pay/index')}<else/>{:U('Pay/quick')}</gt>" id="payment_{$data['id']}" data-ajax="false" method="POST">
      <div class="order-detail">
        <!-- 基本信息 -->
        <h4>基本信息</h4>
        <ul class="table-view base">
          <li class="table-view-cell">
            <span class="th">订单编号：</span>
            {$data['order_sn']}
          </li>
          <li class="table-view-cell">
            <span class="th">下单时间：</span>
            {$data['create_time']|time_format}
          </li>
          <li class="table-view-cell">
            <span class="th">收货地址：</span>
            {$data.ship.ship_uname}<br>
            {$data.ship.ship_area}<br>
            {$data.ship.ship_address}<br>
            {$data.ship.ship_mobile}
          </li>
          <li class="table-view-cell">
            <span class="th">包裹数：</span>
            {$data['total_package']}个<span class="attachment">（含{$data['total_quantity']}件商品）</span>
          </li>
          <notempty name='data.memo'>
          <volist name='data.memo' id='vo'>
          <li class="table-view-cell">
            <span class="th">备注：</span>
            {$key}:{$vo}
          </li>
          </volist>
          </notempty>
          <notempty name='data.invoice_des'>
          <li class="table-view-cell">
            <span class="th">发票信息</span>
            <volist name='data.invoice_des' id='vo'>
              {$vo}<br />
            </volist>
          </li>
          </notempty>
          <notempty name='data.realname'>
          <li class="table-view-cell">
            <span class="th">真实姓名</span>
              {$data.realname}
          </li>
          <li class="table-view-cell">
            <span class="th">身份证号</span>
              {$data.idcard}
          </li>
          </notempty>

        </ul>
        <!-- 包裹及配送信息 -->
        <h4>包裹及配送信息</h4>
        <volist name="data.store_list.store" id="kk">
        <ul class="table-view base package">
          <php>$store_name = get_store_text($key);</php>
          <php>$store_info = $data['store_list']['delivery'][$key];$ship_info = $data['store_list']['Ship'][$key];</php>
          <li style="padding:10px; border-bottom:dashed 1px #eeeeee">所属店铺：{$store_name}</li>
          <volist name="kk" id="vo" key='k'>
            <li class="table-view-cell" data-href="{:U('Item/detail', array('id' => $vo['item_id']))}">
              <span class="thumb"><img src="__ROOT__{:get_image_thumb($vo['cover_path'], 100, 100)}" alt="{$vo.name}"></span>
              <span class="name">{$vo.name}<if condition="$vo[price] eq 0"><span class="text-danger">（赠品）</span></if></span>
              <span class="spec">{:custom_unserialize($vo['spec'], 1, '，')}</span>

              <span class="price">
                {$vo.price}元 
                <gt name="vo.quantity" value="0">
                  &times; {$vo.quantity}
                </gt>
                <gt name="vo.fugou_dis_price" value="0">
                <span class="text-danger">（老客户立减）</span>
                </gt>
                <notempty name="vo.memo">
                  <span class="text-danger">（{$vo.memo}）</span>
                </notempty>
              </span>
              <if condition="$store_info.o_status eq 202">
                <notempty name="vo.is_comment">
                  <a href="javascript:comment.detail({$data.uid}, {$vo.item_id}, {$data['id']});" class="btn btn-default">评价详情</a>
                <else/>
                  <a href="javascript:comment.add({$vo.item_id}, {$data['id']});" class="btn btn-positive">立即评价</a>
                </notempty>
              </if>
            </li>
          </volist>
        </ul>
         <ul class="table-view base border-none">
         <!-- 订单状态 -->
         <li class="table-view-cell">
          <span class="th">订单状态：</span>
          <if condition="$store_info['o_status'] neq 405">
            <strong>{$store_info.o_status|get_order_status_text}</strong>
          <else />
            <strong>
              <?php if($store_info['complete_time'] > 0){?>
                【售后驳回】订单完成
              <?php }elseif($store_info['shipping_time'] >0){?>
                【售后驳回】商品配送中
              <?php }else{?>
                暂无
              <?php }?>
            </strong>
          </if>
         </li>
         <!-- 物流详情 -->
          <notempty name="ship_info">
            <li class="table-view-cell"><span class="th">快递公司：</span>{$ship_info.delivery_name}</li>
            <li class="table-view-cell"><span class="th">快递单号：</span>{$ship_info.delivery_sn}
              <a href="javascript:$.ui.load('{:U('Order/getDelivery?order_id='.$store_info['id'])}', '物流配送信息');" class="btn delivery_info_btn hidden Z_delivery_info_btn btn-default">查看物流</a>
            </li>
          </notempty>
          <!-- 订单操作按钮 -->
          <li class="table-view-cell">
            <switch name="store_info.o_status">
              <case value="-3|200">
                <a class="msg btn pos-rel" href="javascript:order.refund({$store_info['id']});">申请售后</a>
              </case>
              <case value="201">
                <a href="javascript:order.confirm({$store_info['id']});" class="btn pos-rel  btn-positive">确认收货</a>
                <a class="msg btn pos-rel btn" href="javascript:order.refund({$store_info['id']});">申请售后</a>
              </case>
              <case value="202">
              <php>$complete_time = (float)$store_info['complete_time']; $end_time = time()-C('MAX_REFUND_CASH_DAY')*24*3600;</php>
               <empty name='store_info.refuse_message' >
                <if condition="$complete_time gt $end_time">
                  <a href="javascript:order.refund({$store_info['id']});" class="msg btn pos-rel">申请售后</a>
                </if>
                </empty>
              </case>
              <case value="300">
                <a class="msg pos-rel btn" href="javascript:order.unrefund({$store_info['id']});">撤销售后申请</a>
              </case>
              <case value="301">
                <a href="javascript:$.ui.load('{:U('Order/reShip',array('order_id' => $store_info['id']))}','退货信息');" class="btn pos-rel">立即退货</a>
              </case>
              <case value="405">
                <if condition="$store_info['complete_time'] eq 0">
                  <a href="javascript:order.refund({$store_info['id']});" class="msg btn pos-rel">申请售后</a>
                  <a href="javascript:order.confirm({$store_info['id']});" class="btn pos-rel  btn-positive">确认收货</a>
                </if>
              </case>
              <case value="302">
                <span class="th">退货信息：</span> {$store_info['reship_info_text']['company_name']} （{$store_info['reship_info_text']['ship_number']}）
              </case>
            </switch>
          </li>
          </ul>
        </volist>
        <!-- 结算清单 -->
        <h4>结算清单</h4>
        <ul class="table-view base">
          
          <li class="table-view-cell">
            <span class="th">商品总价：</span>
            {$data.total_price} 元
          </li>
          <li class="table-view-cell">
            <span class="th">运费总额：</span>
            + {$data.delivery_fee} 元
          </li>
          <eq name="data.payment.is_use_coupon" value="1">
          <li class="table-view-cell">
            <span class="th" style="text-indent: 1em;">优惠券：</span>
            - {$data.payment.coupon_amount} 元
          </li>
          </eq>
          <eq name="data.payment.is_use_card" value="1">
          <li class="table-view-cell">
            <span class="th" style="text-indent: 1em;">礼品卡：</span>
            - {$data.payment.card_amount} 元
          </li>
          </eq>
          <gt name="data.payment.score_amount" value="0">
            <li class="table-view-cell">
            <span class="th">积分抵扣：</span>
            - {$data.payment.score_amount} 元
            </li>
          </gt>
          <gt name="data.payment.manjian" value="0">
            <li class="table-view-cell">
              <span class="th">满减金额：</span>
            - {$data.payment.manjian} 元
            </li>
          </gt>
          <if condition="$data['discount_amount'] gt 0">
          <li class="table-view-cell">
            <span class="th">优惠金额：</span>
            {$data.discount_amount} 元
          </li>
          </if>
          <php>$amount = sprintf('%.2f', $data['finance_amount']+$data['total_amount']);</php>
          <li class="table-view-cell">
          <if condition="$data['payment_time'] gt 0">
            <span class="th">实际支付：</span>
            <em class="text-danger">{$amount}</em> 元
           <gt name='amount' value='0'>
            <p class="amount-info">
              （<if condition="$data['finance_amount'] gt 0">余额：{$data.finance_amount} 元</if>
              <if condition="$data['finance_amount'] gt 0 AND $data['total_amount'] gt 0">+</if>
              <gt name="data.total_amount" value="0">
                {$data.payment.payment_type|get_payment_type_text}：{$data.total_amount}</b> 元
              </gt>
              ）
            </p>
            </gt> 
            
            <else />
            <span class="th">应付金额：</span>
            <em class="text-danger">{$amount}</em> 元
            <span class="amount-info">
              （<if condition="$data['finance_amount'] gt 0">余额：{$data.finance_amount} 元</if>
              <if condition="$data['finance_amount'] gt 0 AND $data['total_amount'] gt 0">+</if>
              <gt name="data.total_amount" value="0">
                第三方支付：{$data.total_amount}</b> 元
              </gt>）
            </span>
          </if>
          </li>
          
        </ul>
        <eq name="data.o_status" value="0">
        <h4>订单操作</h4>
        <ul class="table-view base">
          <li class="table-view-cell">
            <span class="th">订单状态：</span>
            <strong>{$data.o_status|get_order_status_text}</strong>
          </li>
        </ul>
        </eq>
        <!-- 订单操作按钮 -->
          <switch name="data.o_status">
            <case value="0">
              <em class="timer">{$data['timer']}</em>
              <input type="hidden" name="order_id" value="{$data['id']}">
              <input type="hidden" name="total_amount" class="Z_total_amount" value="{$data.total_amount}">
              <input type="hidden" name="payment_type" class="Z_payment_type" value="{$data.payment_type}">
              <!-- 众筹订单 -->
              <eq name="data.order_type.name" value="crowdfunding">
                <a href="{:U('Crowdfunding/doing', array('id' => $data['order_type']['data']['id'], 'oid' => $data['id']))}" class="btn btn-block btn-positive"><eq name="data.order_type.data.has_finish" value="1">众筹完成<else/>正在众筹…</eq></a>
              <else/>
                <!-- 余额、卡券支付 or 第三方支付 -->
                <eq name="data.total_amount" value="0">
                  <div class="quick-pay">
                    <div class="control-group">
                      <input type="tel" name="mobile" value="{:session('user_auth.mobile')}" disabled="1"><span class="btn btn-randcode">限注册手机</span>
                    </div>
                    <div class="control-group">
                      <input type="text" name="verify" id="verify" maxlength="4" placeholder="图形验证码">
                      <img class="verifyimg J_reload_verify" style="width: 86px; height: 30px; position: absolute; right: 10px; top:8px;" title="点击更换" src="{:U('User/verify')}">
                    </div>
                    <div class="control-group">
                      <input type="tel" name="randcode" class="last Z_mobile_randcode" maxlength="6" placeholder="支付验证码">
                      <a href="javascript:;" class="btn btn-primary btn-randcode Z_mobile_randcode_button" data-geturl="{:U('User/sendMobileCode')}">获取支付验证码</a>
                    </div>
                    <div class="control-action">
                      <a href="javascript:order.quick_pay({$data['id']});" class="btn btn-positive btn-block">立即支付</a>
                    </div>
                  </div>
                <else/>
                <!--{//此处只为截断样式 }--> 
                <h4 class="payment-type border-none">支付方式</h4>
                <div class="content-padded">
                  <select name="payment_type" id="payment_type" class="Z_payment_type">
                    <if condition="is_weixin()">
                    <option value="wechatpay" <eq name="data.payment_type" value="wechatpay">selected="selected"</eq>>微信支付</option>
                    </if>
                    <option value="alipaywap" <eq name="data.payment_type" value="alipaywap">selected="selected"</eq>>支付宝支付</option>
                  </select>
                </div>
                <div class="content-padded">
                  <button class="btn btn-block btn-positive">立即支付</button>
                </div>
                </eq>
                <div class="content-padded">
                  <a href="javascript:order.setStatus({$data['id']}, 'cancel');" class="btn btn-block">取消订单</a>
                </div>
              </eq>
            </case>
          </switch>
      </div>
    </form>
  </div>
  <style type="text/css">
  .pos-rel{ position: relative; top: 20px; margin-left: 20px ; float: right; }
</style>
</block>


<block name="script">
  <script type="text/javascript">
    var order, comment;
    seajs.use(['order', 'comment','user'], function(o, c,user){
      order = o;
      comment = c;
      user.getRandCode('quickPay');
    });
  </script>
</block>